'''
Created on Dec 29, 2012

@author: peng
'''
import datetime
from calendar import monthrange


def get_month_day_range(date_string, date_fromat):
    '''get month day range'''
    date = datetime.datetime.strptime(date_string, date_fromat)
    month_days = monthrange(date.year, date.month)[1]
    start_date = datetime.datetime(date.year, date.month, 1)
    end_date = start_date + datetime.timedelta(days=month_days - 1)
    return start_date, end_date


print get_month_day_range('201202', '%Y%m')
